<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js"></script>
</head>
<body>
<div id="app">
    <button @click="firstName='Wang'">修改姓名</button>
    <button @click="getFullName='Wang PEIHUA'">修改姓名--getFullName</button>
    <h1>{{fullName}}</h1>
    <h1>{{fullName}}</h1>
    <h1>{{fullName}}</h1>
    <h1>{{getFullName}}</h1>
</div>
<script>
    Vue.config.productionTip = false
    const vm = new Vue({
        el: '#app',
        data() {
            return {
                firstName:'Li',
                lastName:'PEIHUA'
            }
        },
        computed:{
            fullName(){
                console.log('计算')
                return this.firstName.toLowerCase()+' '+this.lastName.toLowerCase()
            },
            getFullName:{
                get(){
                    return this.firstName.toLowerCase()+' '+this.lastName.toLowerCase()
                },
                set(val){
                    this.firstName = val.split(' ')[0]
                    this.lastName = val.split(' ')[1]
                }
            }
        }
    })
</script>
</body>
</html>